//导入模型
const { Weight_Support_link } = require('../../models/Course outline/weight_Support_link')
const { Class_Target } = require('../../models/Course outline/class_Target')
const { Weight_Support_link_illustrate } = require('../../models/Course outline/weight_Support link_illustrate')
const { Level_1_assessment } = require('../../models/Course outline/Level_1_assessment')
const { Index_Point } = require('../../models/Course outline/index_Point')

//一级考核指标
exports.Get_Level_1_assessment = async (req, res) => {
  const { t_user_and_a_c_s_id } = req.query;

  try {
    const classes = await Level_1_assessment.findAll({
      where: {
        t_user_and_a_c_s_id: t_user_and_a_c_s_id,
      },
    });

    if (classes.length === 0) {
      return res.json({
        'code': 203,
        'msg': '没有对应数据'
      });
    }

    res.json({
      'code': 200,
      'msg': '查询成功',
      'data': classes
    });
  } catch (error) {
    console.error('查询数据失败:', error);
    res.json({
      'code': 500,
      'msg': '查询失败'
    });
  }
};


//课程目标	支撑环节	权重系数 查询查找
exports.getWeight_Support_link = async (req, res) => {
  const { t_user_and_a_c_s_id } = req.query;

  try {
    const classes = await Weight_Support_link.findAll({
      where: {
        t_user_and_a_c_s_id: t_user_and_a_c_s_id,
      },
    });

    if (classes.length === 0) {
      return res.json({
        'code': 203,
        'msg': '没有对应数据'
      });
    }

    res.json({
      'code': 200,
      'msg': '查询成功',
      'data': classes
    });
  } catch (error) {
    console.error('查询数据失败:', error);
    res.json({
      'code': 500,
      'msg': '查询失败'
    });
  }
};

//说明查询查找
exports.Get_Weight_Support_link_illustrate = async (req, res) => {
  const { t_user_and_a_c_s_id } = req.query;

  try {
    const classes = await Weight_Support_link_illustrate.findAll({
      where: {
        t_user_and_a_c_s_id: t_user_and_a_c_s_id,
      },
    });

    if (classes.length === 0) {
      return res.json({
        'code': 203,
        'msg': '没有对应数据'
      });
    }

    res.json({
      'code': 200,
      'msg': '查询成功',
      'data': classes
    });
  } catch (error) {
    console.error('查询数据失败:', error);
    res.json({
      'code': 500,
      'msg': '查询失败'
    });
  }
};